package com.anolesoft.amljmes.foreknow.knowwebservice.service.impl;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.anolesoft.amljmes.foreknow.knowwebservice.dto.MesBzzFcfhjhDtoDao;
import com.anolesoft.amljmes.foreknow.knowwebservice.mapper.QjwlWebMapper;
import com.anolesoft.amljmes.foreknow.knowwebservice.service.QjwlWebService;
import com.anolesoft.amljmes.fortysix.dto.MesBzzPtmlDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QjwlWebServiceImpl implements QjwlWebService {

    @Autowired
    private QjwlWebMapper mapper;

    @Override
    public String jianyan(String password2, String fcode) {
        return mapper.jianyan(password2,fcode);
    }

    @Override
    public MesBzzPtmlDto toPtml(MesBzzPtmlDto mesBzzPtmlDto) {
        return mapper.toPtml(mesBzzPtmlDto);
    }


    @Override
    public int insertFcfhjhfanghu(MesBzzFcfhjhDtoDao mesBzzFcfhjhDtoDao) {
        return mapper.insertFcfhjhfanghu(mesBzzFcfhjhDtoDao);
    }

    @Override
    public int insertFcfhjhfengcun(MesBzzFcfhjhDtoDao mesBzzFcfhjhDtoDao) {
        return mapper.insertFcfhjhfengcuyn(mesBzzFcfhjhDtoDao);
    }

    @Override
    public String hgbqtm(String zzjltm) {
        return mapper.hgbqtm(zzjltm);
    }
    /**
     * 根据合格标签条码获取order和fcfhjh的数据(内部封存入库)
     * @param hgbqtm
     * @return
     */
    @Override
    public String getDataByhgbq(String hgbqtm) {
        MesBzzFcfhjhDtoDao mesBzzFcfhjhDtoDao = mapper.getDataByhgbq(hgbqtm);
        JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(mesBzzFcfhjhDtoDao));
        return jsonObject.toString();
    }

    /**
     * 修改封存防护计划状态
     * @param hgbqbh
     * @return
     */
    @Override
    public int updateFcfhjh(List<String> hgbqbh , String wcr) {
        int a = 0;
        for (String hgbqtm:
                hgbqbh) {
            a = mapper.updateFcfhjh(hgbqtm,wcr);
            mapper.updateOrderState(hgbqtm);
            a++;
        }
        return a;
    }
}
